package com.gonsin.gview.model.dynamic.form;

import com.gonsin.gview.annotations.GContext;
import com.gonsin.gview.annotations.enums.ButtonAction;
import com.gonsin.gview.model.dynamic.DynamicButton;
import com.gonsin.gview.model.dynamic.DynamicView;
import com.gonsin.gview.model.dynamic.data.DynamicData;

import java.util.List;

public interface DynamicFormView extends DynamicView {

    /**
     * 该表单中的数据源
     */
    DynamicData data(GContext context);

    /**
     * 表单项内容
     */
    List<DynamicFormItem> formItems(GContext context);

    /**
     * 取消按钮
     */
    default DynamicButton cancelButton(GContext context){
        return null;
    }

    /**
     * 确认按钮的信息
     */
    default DynamicButton okButton(GContext context){
        return DynamicButton.builder().action(ButtonAction.CLOSE_DIALOG).name("取消").build();
    }

}
